<?php
/**
 * Created by IntelliJ IDEA.
 * User: HXL
 * Date: 2018/9/29
 * Time: 17:21
 */
namespace app\order\model;

use think\Db;
class Supplies extends BaseModel{
    protected $tableName = 'ari_supply';

    public function page($field = '*', $where = '', $order = ''){
        $num = 10;
        $count = $this->count($where);
        $data = Db::table($this->tableName)->field($field)->where($where)
            ->order($order)->join('ari_model_types model', $this->tableName.'.mod_id=model.model_id')
            ->paginate($num, $count, ['query' => request()->param()]);
        return $data;
    }

    public function search($search){
        $num = 10;
        $count = Db::table($this->tableName)->where('sup_id', 'like', "%$search%")
            ->whereOr('sup_type', 'like', "%$search%")
            ->whereOr('provider', 'like', "%$search%")->count();
        $data = Db::table($this->tableName)->where('sup_id', 'like', "%$search%")
            ->whereOr('sup_type', 'like', "%$search%")
            ->whereOr('provider', 'like', "%$search%")
            ->join('ari_model_types model', $this->tableName.'.mod_id=model.model_id')
            ->paginate($num, $count, ['query' => request()->param()]);
        return $data;
    }


}